package com.zhiyou.crud.controller;

import com.zhiyou.crud.bean.Department;
import com.zhiyou.crud.bean.Msg;
import com.zhiyou.crud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author leibusi
 * @desc
 * @create 2021-10-19 11:21
 */
@Controller
public class DeptController {
    @Autowired
    DeptService deptService;
    /*
    * 返回所有的部门信息
    * */
    @RequestMapping("/depts")
    @ResponseBody
    public Msg getDepts(){
        //查出所有部门信息
        List<Department> list = deptService.getDepts();
        return Msg.success().add("depts",list);
    }

    @RequestMapping("/insertDept")
    public String insertDept(Department dept){
        //实现部门的添加
        return "list2";
    }
}
